#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <cctype>
#include <set>

namespace uvu
{
#define LOCAL ____________DONT_DEFINE_ME____________
#define ll long long
#define inf 0x3f3f3f3f
// #define int long long
// #define inf 0x3f3f3f3f3f3f3f3fll
#define infll 0x3f3f3f3f3f3f3f3fll
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define gline debug("now is #%d\n", __LINE__)
#define pii std::pair <int, int>
#define mkp std::make_pair
#define fi first
#define se second
char _ST_;
const int BUFSIZE = (1 << 20);
char ibuf[BUFSIZE], *iS = ibuf, *iT = ibuf;
char obuf[BUFSIZE], *oS = obuf, *oT = obuf + BUFSIZE;
char getc()
{
#ifdef LOCAL
	return getchar();
#else
	if(iS == iT) iT = (iS = ibuf) + fread(ibuf, 1, BUFSIZE, stdin);
	return iS == iT ? EOF : *iS++;
#endif
#define getchar ERR
}

void Flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; }
struct Flusher { ~Flusher(){ Flush(); } }iamflusher;

void putc(char c)
{
#ifdef LOCAL
	putchar(c);
#else
	*oS++ = c;
	if(oS == oT) Flush();
#endif
#define putchar ERR
}

template <typename T = int> T read()
{
	T x = 0, f = 1; char c = getc();
	for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
	for(;  isdigit(c); c = getc()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

template <typename T> void print(T x, char c)
{
static int sta[BUFSIZE], top;
	top = 0;
	if(x < 0) putc('-'), x = -x;
	if(!x) sta[top = 1] = 0;
	for(; x; x /= 10) sta[++top] = x % 10;
	for(; top; ) putc(sta[top--] ^ 48);
	if(c) putc(c);
}

int readstr(char *s, int base)
{
	int idx = base - 1; char c = getc();
	for(; !(isdigit(c) || isalpha(c) || c == '#' || c == '.'); c = getc());
	for(;   isdigit(c) || isalpha(c) || c == '#' || c == '.' ; c = getc()) s[++idx] = c;
	return idx - base + 1;
}

void printf(const char *s) { for(; *s; s++) putc(*s); }
template <typename T, typename ... Args>
void printf(const char *s, T x, Args ... rest)
{
	for(; *s; s++)
	{
		if(*s != '%') { putc(*s); continue; }
		s++; if(*s == 'd') print(x, 0);
		else if(*s == 'c') putc(x);
		printf(s + 1, rest ...);
		return;
	}
}

template <typename T> void ckmax(T &x, T y) { x = x > y ? x : y; }
template <typename T> void ckmin(T &x, T y) { x = x < y ? x : y; }
#define mod 998244353
// #define mod 1000000007
int sm(int x) { return x >= mod ? x - mod : x; }
void plus_(int &x, int y) { x = sm(x + y); }
void mul_(int &x, int y) { x = 1ll * x * y % mod; }
int ksm(int a, int b) { int res = 1; for(; b; b >>= 1, mul_(a, a)) if(b & 1) mul_(res, a); return res; }

#define N 100010
int n, rt, A, B, du[N];
int h[N], e[N << 1], ne[N << 1], idx = -1;
void add_edge(int x, int y) { ne[++idx] = h[x], h[x] = idx, du[e[idx] = y]++; }
void add(int x, int y) { add_edge(x, y), add_edge(y, x); }

namespace Sub1
{
int fdfn[N], dfn[N];
void dfs(int k, int fa)
{
	fdfn[dfn[k] = ++dfn[0]] = k;
	for(int i = h[k]; ~i; i = ne[i]) if(e[i] != fa) dfs(e[i], k);
}
int f[N][2], d[N][2], tag[N];
void solve()
{
	dfs(rt, 0);
	int ans = inf;
	f[1][0] = 1;
	for(int i = 1; i <= n; i++)
	{
		d[i][1] += d[i - 1][1];
		if(d[i][1]) f[i][1] = 1;
		if(f[i][1])
		{
			tag[std::max(i - B, 1)]++;
			tag[i]--;
			d[i][0]++;
			d[std::min(i + B + 1, n + 1)][0]--;
		}
		d[i][0] += d[i - 1][0];
		if(d[i][0]) f[i][0] = 1;
		if(f[i][0])
		{
			if(i + A <= n) f[i + A][1] = 1;
			else 
			{
				tag[i]++;
				tag[std::min(n + 1, i + B + 1)]--;
			}
		}
	}
	for(int i = 1; i <= n; i++) 
	{
		tag[i] += tag[i - 1];
		if(tag[i]) ckmin(ans, fdfn[i]);
	}
	print(ans, '\n');
}
}

namespace Sub2
{
int f[N][2][2];
std::vector <int> vec[N];
int sta[N], top, fa[N];
int dfn[N], out[N], fdfn[N];
void dfs0(int k, int fa)
{
	fdfn[dfn[k] = ++dfn[0]] = k;
	sta[++top] = k; Sub2::fa[k] = fa;
	if(top > A) vec[sta[top - A]].push_back(k);
	for(int i = h[k]; ~i; i = ne[i]) if(e[i] != fa) dfs0(e[i], k);
	top--; out[k] = dfn[0];
}
int dfs1(int k, int fa, int d)
{
	int res = k; if(!d) return res;
	for(int i = h[k]; ~i; i = ne[i]) if(e[i] != fa) ckmin(res, dfs1(e[i], k, d - 1));
	return res;
}
int calc(int k, int x, int op);
int dfs2(int k, int fa, int ffa, int d)
{
	int res;
	// printf("fa = %d (%d)\n", fa, Sub2::fa[k]);
	if(ffa == Sub2::fa[k]) res = calc(k, 0, 0);
	else res = calc(ffa, 1, 0); 
	if(!d) return res;
	for(int i = h[k]; ~i; i = ne[i]) if(e[i] != fa) ckmin(res, dfs2(e[i], k, k, d - 1));
	return res;
}
int calc(int k, int x, int op)
{
	if(~f[k][x][op]) return f[k][x][op];
	int &res = f[k][x][op];
	if(!op)
	{
		int sz = 0;
		if(!x) sz = (int)vec[k].size();
		else
		{
			int p = fa[k];
			for(int nx : vec[p]) if(!(dfn[k] <= dfn[nx] && dfn[nx] <= out[k]))
				sz++;
		}
		if(!sz)
		{
			if(!x) res = dfs1(k, fa[k], B);
			else 
			{
				int p = fa[k]; res = p;
				for(int i = h[p]; ~i; i = ne[i]) if(e[i] != fa[p] && e[i] != k) ckmin(res, dfs1(e[i], k, B - 1));
			}
		}
		else
		{
			res = 0;
			if(!x) 
			{
				for(int nx : vec[k]) ckmax(res, calc(nx, 0, 1));
			}
			else
			{
				int p = fa[k];
				for(int nx : vec[p]) if(!(dfn[k] <= dfn[nx] && dfn[nx] <= out[k]))
					ckmax(res, calc(nx, 0, 1));
			}
		}
	}
	else
	{
		// if(!x) res = dfs2(k, fa[k], B);
		// else
		// {
		// 	int p = fa[k]; res = calc(p, 1, 0);
		// 	for(int i = h[p]; ~i; i = ne[i]) if(e[i] != fa[p] && e[i] != k) ckmin(res, dfs2(e[i], k, B - 1));
		// }
		res = dfs2(x ? fa[k] : k, 0, x ? k : Sub2::fa[k], B);
	}
	// printf("f[%d][%d][%d] = %d\n", k, x, op, f[k][x][op]);
	return f[k][x][op];
}
void solve()
{
	memset(f, -1, sizeof(f));
	dfs0(rt, 0);
	int ans = calc(rt, 0, 0);
	print(ans, '\n');
}
}

void solve()
{
	memset(h, idx = -1, sizeof(h));
    n = read(), rt = read(), A = read(), B = read();
	for(int i = 1; i < n; i++) add(read(), read());
	if(A <= B) { print(1, '\n'); return; }
	if(du[rt] == 1 && std::count(du + 1, du + 1 + n, 2) == n - 2) return Sub1::solve();
	Sub2::solve();
}

void init()
{

}

char _ED_;

void mian()
{
	debug("%.3f MB\n", abs(&_ST_ - &_ED_) / 1024.0 / 1024);
	init();
	for(int T = 1; T; solve(), T--);
}

#ifdef int
	#undef int
#endif
}

int main()
{
	freopen("nim.in", "r", stdin);
	freopen("nim.out", "w", stdout);
	uvu::mian(); return 0;
}